package top.yamhk.agent.entity.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * 基础资源实体类
 *
 * @author 庆 HongKong
 * @date 2020/8/21 0:15
 */
@Data
@EqualsAndHashCode(of = {"value", "originId"}, callSuper = true)
public class BaseSrc extends AnyKernel implements Comparable<BaseSrc> {
    @JsonIgnore
    private String id = "0";
    @JsonIgnore
    private String originId = "-1";
    private Integer level = 0;
    private String value = "/";
    private String label = "/";
    private String path = "/";
    @JsonIgnore
    private boolean enable = true;

    @Override
    public int compareTo(BaseSrc o) {
        return Integer.parseInt(this.getId()) - Integer.parseInt(o.getId());
    }

    /**
     * 逻辑删除
     *
     * @return boolean
     */
    public Object logicDelete() {
        return this;
    }

    public Object convertToResponse(Class clazz) {
        Object response = null;
        try {
            response = clazz.newInstance();
        } catch (InstantiationException | IllegalAccessException e) {
            e.printStackTrace();
        }
//        BeanCopyUtils.copyProperties(this, response);
        return response;
    }

    public boolean visible(AnyKernel kernelNode) {
        return false;
    }
}